package com.anzia.study_4.slice;

import com.anzia.study_4.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Text;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

public class MainAbility_CalculatorSlice extends AbilitySlice {

	private static final HiLogLabel LOG_LABEL = new HiLogLabel(HiLog.LOG_APP, 0x101001, "anzia");

	@Override
	public void onStart(Intent intent) {
		super.onStart(intent);
		super.setUIContent(ResourceTable.Layout_ability_main_calculator);

		HiLog.info(LOG_LABEL, "进入start方法");

		Text text;
		Button btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btn_x, btn0, btn_jin, btn_call;

		text = (Text) findComponentById(ResourceTable.Id_text_number);
		text.setTruncationMode(Text.TruncationMode.AUTO_SCROLLING);
		text.startAutoScrolling();

		btn1 = (Button) findComponentById(ResourceTable.Id_btn_1);
		btn1.setClickedListener(component -> {
			text.setText(text.getText() + "1");
		});
		btn2 = (Button) findComponentById(ResourceTable.Id_btn_2);
		btn2.setClickedListener(component -> {
			text.setText(text.getText() + "2");
		});
		btn3 = (Button) findComponentById(ResourceTable.Id_btn_3);
		btn3.setClickedListener(component -> {
			text.setText(text.getText() + "3");
		});
		btn4 = (Button) findComponentById(ResourceTable.Id_btn_4);
		btn4.setClickedListener(component -> {
			text.setText(text.getText() + "4");
		});

		btn5 = (Button) findComponentById(ResourceTable.Id_btn_5);
		btn5.setClickedListener(component -> {
			text.setText(text.getText() + "5");
		});

		btn6 = (Button) findComponentById(ResourceTable.Id_btn_6);
		btn6.setClickedListener(component -> {
			text.setText(text.getText() + "6");
		});

		btn7 = (Button) findComponentById(ResourceTable.Id_btn_7);
		btn7.setClickedListener(component -> {
			text.setText(text.getText() + "7");
		});

		btn8 = (Button) findComponentById(ResourceTable.Id_btn_8);
		btn8.setClickedListener(component -> {
			text.setText(text.getText() + "8");
		});

		btn9 = (Button) findComponentById(ResourceTable.Id_btn_9);
		btn9.setClickedListener(component -> {
			text.setText(text.getText() + "9");
		});

		btn_x = (Button) findComponentById(ResourceTable.Id_btn_xin);
		btn_x.setClickedListener(component -> {
			text.setText(text.getText() + "*");
		});

		btn0 = (Button) findComponentById(ResourceTable.Id_btn_0);
		btn0.setClickedListener(component -> {
			text.setText(text.getText() + "0");
		});

		btn_jin = (Button) findComponentById(ResourceTable.Id_btn_jin);
		btn_jin.setClickedListener(component -> {
			text.setText(text.getText() + "#");
		});

		btn_call = (Button) findComponentById(ResourceTable.Id_btn_call);


	}

	@Override
	public void onActive() {
		super.onActive();
	}

	@Override
	public void onForeground(Intent intent) {
		super.onForeground(intent);
	}
}
